<template>
	<view class="subscribe">
		<view class="nav" >
			<view v-for="item in navlist" :key="item.id" :class="{
				'li': true,
				'okli': item.id === navlistnum
			}" @click="updateLIstClass(item.id, item.router)">
				{{ item.name }}
			</view>
		</view>
		<!-- 时间 -->
		<view class="contentCard" v-show="showCard === 'hr-card'">
			<mx-datepicker :show="isTime" :type="timeType" :value="value" :show-tips="true" :begin-text="'入住'" :end-text="'离店'" :show-seconds="true" @confirm="timeOnSelected" @cancel="timeOnSelected" />
			<mx-datepicker :show="isDate" :type="dateType" :value="value" :show-tips="true" :begin-text="'入住'" :end-text="'离店'" :show-seconds="true" @confirm="timeOnSelected" @cancel="timeOnSelected" />
			<view class="message" style="text-align: center;">
				{{firstTime || '请选择开始时间'}} :
				{{endTime || '请选择结束时间'}}
			</view>
			<view class="" style="display: flex;">
				<button type="default" @click="onShowDatePicker('firstTime', 'time')" class="selectBtn">
					选择开始时间
				</button>
				<button type="default" @click="onShowDatePicker('endTime', 'time')" class="selectBtn">
					选择结束时间
				</button>
			</view>
		</view>
		<!-- 日期 -->
		<view class="contentCard" v-show="showCard === 'day-card'">
			<mx-datepicker :show="isTime" :type="dateType" :value="value" :show-tips="true" :begin-text="'入住'" :end-text="'离店'" :show-seconds="true" @confirm="timeOnSelected" @cancel="timeOnSelected" :showSeconds="true" />
			<mx-datepicker :show="isDate" :type="dateType" :value="value" :show-tips="true" :begin-text="'入住'" :end-text="'离店'" :show-seconds="true" @confirm="timeOnSelected" @cancel="timeOnSelected" :showSeconds="true" />
			<view class="message" style="text-align: center;">
				{{firstDate || '请选择开始日期'}} :
				{{endDate || '请选择结束日期'}}
			</view>
			<view class="" style="display: flex;">
				<button type="default" @click="onShowDatePicker('firstDate', 'data')" class="selectBtn">
					选择开始日期
				</button>
				<button type="default" @click="onShowDatePicker('endDate', 'data')" class="selectBtn">
					选择结束日期
				</button>
			</view>
		</view>
		<!-- 选座 -->
		<view class="xz">
			<view v-for="(item,index) in xzList" :key="item.id" :class="{
				'xzli': true,
				'okxzli': item.id === xzListnum
			}" @click="updatexzclass(item.id); ifxuanzuoFun()">
				<view class="">
					{{ item.name }}
				</view>
				<view class="">
					{{ item.text }}
				</view>
			</view>
		</view>
		<!-- 弹窗 -->
		<Xuan-Zuo v-if="ifxuanzuo" @gainian="ifxuanzuoFun()" @zhifu="zhifuFun()"></Xuan-Zuo>
		<view class="jinru" v-if="shwoioc">
			<image src="../../static/jr.png" mode="" class="jinru-img"></image>
		</view>
		
	</view>
</template>

<script>
	import mxDatepicker from '../mx-datepicker/mx-datepicker.vue'
	export default {
		name:"subscribeC",
		components:{mxDatepicker},
		data() {
			return {
				navlist: [
					{
						id:0,
						name: '小时卡',
						router: 'hr-card'
						
					},
					{
						id:1,
						name: '天卡',
						router: 'day-card'
					}
				],
				navlistnum: 0,
				navlistrouter: 'hr-card',
				showPicker: false,
				date: '2019/01/01',
				time: '15:00:12',
				datetime: '2019/01/01 15:00:12',
				range: ['2019/01/01','2019/01/06'],
				rangetime: ['2019/01/08 14:00','2019/01/16 13:59'],
				timeType: 'time',
				value: '',
				firstTime: '',
				endTime: '',
				firstDate: '',
				endDate: '',
				panduan: '',
				dateType: 'date',
				isDate: false,
				isTime: false,
				showCard: 'hr-card',
				xzList: [
					{
						id:0,
						name: '开放室',
						text: '大家面对学习，感受学习氛围',
						router: 'hr-card'
						
					},
					{
						id:1,
						name: '纯享室',
						text: '在包间内学习，享受安静环境',
						router: 'hr-card'
						
					},
					{
						id:2,
						name: '讨论室',
						text: '在房间里头脑风暴，想出绝妙好点子',
						router: 'hr-card'
						
					}
				],
				xzListnum: 0,
				ifxuanzuo: false,
				shwoioc: false
			};
		},
		methods: {
			updateLIstClass(id, router) {
				this.xzListnum = 0
				this.navlistnum = id
				this.navlistrouter = router
				this.showCard = router
			},
			onShowDatePicker(type, s1){//显示
				this.type = type;
				s1 === 'time'
					? this.isTime = true
					: this.isDate = true
				this.panduan = type;
			},
			timeOnSelected(e) {//选择
				this.isTime = false
				this.isDate = false
				if(this.panduan === 'firstTime') {
					this.firstTime = e.value; 
				} else if(this.panduan === 'endTime'){
					this.endTime = e.value
				}
				if(this.panduan === 'firstDate') {
					this.firstDate = e.value; 
				} else if(this.panduan === 'endDate') {
					this.endDate = e.value
				}
			},
			updatexzclass(id) {
				this.xzListnum = id
			},
			ifxuanzuoFun() {
				this.ifxuanzuo = !this.ifxuanzuo
			},
			zhifuFun() {
				this.shwoioc = true
			}
		}
	}
</script>

<style lang="scss" scoped>
	.jinru{
		position: absolute;
		right: 0;
		top: 700rpx;
		padding: 5rpx;
		width: 70rpx;
		height: 60rpx;
		background-color: #6bc12d;
		border-radius: 20rpx 0 0 20rpx;
	}
	.jinru-img{
		width: 70rpx;
		height: 60rpx;
		z-index: 5;
	}
	.selectBtn{
		border: 0;
		background-image: linear-gradient(to right, #43e97b 0%, #38f9d7 100%);
		color: #fff;
		font-weight: 600;
		border-radius: 70rpx;
	}
	.okli{
		border-bottom: 2px solid #6bc12d;
	}

	.nav{
		display: flex;
		justify-content: center;
		align-items: center;
		.li{
			padding: 10rpx 3rpx;
			margin-right: 80rpx;
			transition: all 0.2s;
			transform: scale(1);
			font-weight: 600;
		}
	}
	.contentCard{
		box-shadow: 0 0 10rpx 2rpx #d6d6d6;
		padding: 30rpx 16rpx;
		margin-top: 16rpx;
		border-radius: 30rpx;

	}
	.message{
		background-color: rgba(43, 153, 57, .2);
		border-radius: 15rpx;
		color: #6bc12d;
		margin: 0rpx 0 30rpx;
		padding: 30rpx;
		font-size: 32rpx;
	}
	.xz{
		margin-top: 30rpx;
		display: flex;
		align-items: center;
		justify-content: space-evenly;
	}
	.xzli{
		font-size: 25rpx;
		color: rgb(143, 154, 160);
		border: 1rpx solid rgb(143, 154, 160);
		text-align: center;
		width: 180rpx;
		height: 190rpx;
		border-radius: 10rpx;
		padding: 5rpx;
		display: flex;
		flex-direction: column;
	}
	.okxzli {
		border: 1rpx solid #6bc12d !important;
		color: #6bc12d !important;
	}
</style>
